package org.gdpu.model;

import org.gdpu.util.ExcelResources;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by HEWI2 on 12/19/13.
 */

@Entity
public class Student {

    /**
     * 学生学号
     */
    private int studentId;
    /**
     * 学生姓名
     */
    private String studentName;
    /**
     * 学生性别
     */
    private Sex sex;
    /**
     * 学生离校时间
     */
    private Date leaveDate;
    /**
     * 联系电话
     */
    private String phone;
    /**
     * 宿舍长
     */
    private Monitor monitor;
    /**
     * 专业
     */
    private Major major;
    /**
     * 宿舍
     */
    private Dormitory dormitory;

    @Id
    @ExcelResources(title = "学号", order = 1)
    public int getStudentId() {
        return studentId;
    }

    public void setStudentId(int studentId) {
        this.studentId = studentId;
    }

    @Column(nullable = false, length = 10)
    @ExcelResources(title = "姓名", order = 2)
    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public void setSex(Sex sex) {
        this.sex = sex;
    }

    @Temporal(TemporalType.DATE)
    @ExcelResources(title = "离校时间", order = 3)
    public Date getLeaveDate() {
        return leaveDate;
    }

    public void setLeaveDate(Date leaveDate) {
        this.leaveDate = leaveDate;
    }

    @Enumerated(EnumType.ORDINAL)
    @ExcelResources(title = "性别", order = 6)
    @Column(nullable = false,columnDefinition = "INT default 1")
    public Sex getSex() {
        return sex;
    }

    @Enumerated(EnumType.ORDINAL)
    @Column(nullable = false,columnDefinition = "INT default 0")
    @ExcelResources(title = "宿舍角色", order = 4)
    public Monitor getMonitor() {
        return monitor;
    }

    public void setMonitor(Monitor monitor) {
        this.monitor = monitor;
    }

    @ManyToOne
    @JoinColumn(name = "majorId",nullable = false)
    @ExcelResources(title = "专业", order = 8)
    public Major getMajor() {
        return major;
    }

    public void setMajor(Major major) {
        this.major = major;
    }

    @ManyToOne
    @JoinColumn(name = "dormitoryId")
    @ExcelResources(title = "宿舍", order = 7)
    public Dormitory getDormitory() {
        return dormitory;
    }

    public void setDormitory(Dormitory dormitory) {
        this.dormitory = dormitory;
    }

    @Column( length = 15)
    @ExcelResources(title = "电话", order = 5)
    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Student(int studentId,String studentName,Sex sex,Date leaveDate,String phone,Monitor monitor,Major major,Dormitory dormitory){
        super();
        this.studentId = studentId;
        this.studentName = studentName;
        this.sex = sex;
        this.leaveDate = leaveDate;
        this.phone = phone;
        this.monitor = monitor;
        this.major = major;
        this.dormitory = dormitory;
    }

    public Student(){
        super();
    }
}
